﻿using CollegeRevApp.DataModels;
using CollegeRevApp.Web.DataAdapters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace CollegeRevApp.Web.Controllers
{
    /// <summary>
    /// API controller for Review.
    /// Only need POST, PUT, DELETE. GET rolls in with the CollegeController.
    /// </summary>
    public class ReviewController : ApiController
    {
        ICollegeAppAdapter _adapter = new CollegeAppAdapter();

        // POST crapp/review
        public IHttpActionResult Post([FromBody]Review review)
        {
            review = _adapter.AddReview(review);
            return Ok(review);
        }

        // PUT crapp/review/id
        public IHttpActionResult Put(int id, [FromBody]Review review)
        {
            review = _adapter.EditReview(id, review);
            return Ok(review);
        }

        // DELETE crapp/review/id
        public IHttpActionResult Delete(int id)
        {
            Review review = _adapter.DeleteReview(id);
            return Ok();
        }
    }
}
